home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / nihcl-30.lha / nihcl-3.0 / lib / LinkedList.h < prev    next >
C/C++ Source or Header  |  1990-05-20  |  3KB  |  91 lines

  1. #ifndef    LINKEDLIST_H
  2. #define    LINKEDLIST_H
  3.  
  4. /*$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/LinkedList.h,v 3.0 90/05/20 11:23:43 kgorlen Rel $*/
  5.  
  6. /* LinkedList.h -- declarations for singly-linked list
  7.  
  8.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  9.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  10.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  11.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  12.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  13.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  14.  
  15. Author:
  16.     K. E. Gorlen
  17.     Computer Systems Laboratory, DCRT
  18.     National Institutes of Health
  19.     Bethesda, MD 20892
  20.  
  21. $Log:    LinkedList.h,v $
  22.  * Revision 3.0  90/05/20  11:23:43  kgorlen
  23.  * Release for 1st edition
  24.  * 
  25. */
  26.  
  27. #include "SeqCltn.h"
  28. #include "Link.h"
  29.  
  30. class LinkedList: public SeqCltn {
  31.     DECLARE_MEMBERS(LinkedList);
  32. private:
  33.     Link* firstLink;        // pointer to first Link of list
  34.     Link* lastLink;            // pointer to last Link of list
  35.     unsigned count;            // count of items on list
  36.     void errDblLnk(const char* fn, const Link& lnk) const;
  37.     void errEmpty(const char* fn) const;
  38.     void errNotFound(const char* fn, const Object& ob) const;
  39. protected:        // storer() functions for object I/O
  40.     virtual void storer(OIOofd&) const;
  41.     virtual void storer(OIOout&) const;
  42. protected:
  43.     virtual Link& linkCastdown(Object&) const;
  44.     Link* linkCastdown(Object* p) const   { return &linkCastdown(*p); }
  45. public:
  46.     LinkedList();
  47. #ifndef BUG_TOOBIG
  48. // yacc stack overflow
  49.     LinkedList(const LinkedList&);
  50. #endif
  51.     bool operator!=(const LinkedList& a) const    { return !(*this==a); }
  52.     bool operator==(const LinkedList&) const;
  53.     Object* operator[](int i);
  54.     const Object *const operator[](int i) const;
  55.     virtual Object* add(Link&);
  56.     virtual Object* add(Object&);
  57.     virtual Object* addAfter(Link&,Link&);
  58.     virtual Object* addAfter(Object&,Object&);
  59.     virtual Collection& addContentsTo(Collection& cltn) const;
  60.     virtual Object* addFirst(Link&);
  61.     virtual Object* addFirst(Object&);
  62.     virtual Object* addLast(Link&);
  63.     virtual Object* addLast(Object&);
  64.     virtual void deepenShallowCopy();
  65.     virtual Object* doNext(Iterator&) const;
  66.     virtual Object* first() const;
  67.     virtual unsigned hash() const;
  68.     virtual bool includes(const Object& ob) const;
  69.      virtual int indexOf(const Object& ob) const;
  70.     virtual bool isEmpty() const;
  71.     virtual bool isEqual(const Object&) const;
  72.     virtual Object* last() const;
  73.     virtual unsigned occurrencesOf(const Object&) const;
  74.     virtual Object* remove(const Link&);
  75.     virtual Object* remove(const Object&);
  76.     virtual void removeAll();
  77.     virtual Object* removeFirst();
  78.     virtual Object* removeLast();
  79.     virtual void reSize(unsigned newSize);
  80.     virtual unsigned size() const;
  81.     virtual const Class* species() const;
  82. private:                // shouldNotImplement()
  83.     virtual Object*& at(int i);
  84.     virtual const Object *const& at(int i) const;
  85.     virtual void atAllPut(Object& ob);
  86.     virtual int indexOfSubCollection(const SeqCltn& cltn, int start=0) const;
  87.     virtual void replaceFrom(int start, int stop, const SeqCltn& replacement, int startAt =0);
  88. };
  89.  
  90. #endif
  91.